import { Window } from "../../../../component/window/Window";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { PetExploreBattleListPanel } from "./PetExploreBattleListPanel";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { Cache } from "../../../cache/Cache";
import { PetExploreConfig } from "../../../resource/PetExploreConfig";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class PetExploreFailureWindow
    
    export  class PetExploreFailureWindow extends Window
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._battlePetItemArray = [];
            this.setSize(300, 385);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            _windowBg = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            _windowBg.width = 300;
            _windowBg.height = 385;
            $addChildAt(_windowBg, 0);
            this._exploreFailure = new Object /* flash.display.Bitmap */();
            this._exploreFailure.x = 100;
            this._exploreFailure.y = 10;
            this.addChild(this._exploreFailure);
            ObjCreate.createTextField(Language.getString(54471), 80, 60, 80, 20, this, new GTextFormat(FontUtil.songtiName, 14, 15788607));
            this._nameTxt = ObjCreate.createTextField("", 160, 60, 80, 30, this, new GTextFormat(FontUtil.songtiName, 16, 65280, true));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            ObjCreate.createTextField(Language.getString(54472), 80, 87, 220, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(54473), 55, 110, 80, 30, this, new GTextFormat(FontUtil.songtiName, 12, 15788607, true));
            this._tipTxt = ObjCreate.createTextField("", 105, 110, 130, 65, this, new GTextFormat(FontUtil.songtiName, 12, 16711935, true));
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.multiline = true;
            this._tipTxt.htmlText = Language.getString(54474);
            ObjCreate.createTextField(Language.getString(54475), 55, 180, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280));
            this._backTxt = ObjCreate.createTextField("", 133, 215, 80, 20, this, new GTextFormat(FontUtil.songtiName, 12, 15788607, true));
            this._backTxt.htmlText = Language.getString(54476);
            this._backTxt.addEventListener(flash.events.TextEvent.LINK, this.onBackHandler);
            ObjCreate.createBg(15, 265, 270, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBitmap(ImagesConst.BattlePetLabel, 15, 265, this);
            ObjCreate.createTextField(Language.getString(54477), 105, 270, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280));
            this._battleListPanel = new PetExploreBattleListPanel();
            this._battleListPanel.x = 8;
            this._battleListPanel.y = 293;
            this.addChild(this._battleListPanel);
            ObjCreate.createTextField(Language.getString(54477), 105, 270, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280));
            ObjCreate.createTextField(Language.getString(54478), 15, 355, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280, true));
            this._gnumTxt = ObjCreate.createTextField("", 120, 355, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280));
            LoaderHelp.addResCallBack(ResFileConst.petExplore, this.onBitmapLoaderHandler);
            return;
        }

        protected /* override */ updateBtnSize(): void
        {
            super.updateBtnSize();
            _closeBtn.x = this.width - _closeBtn.width;
            _closeBtn.y = 0;
            return;
        }

        public updateData(): void
        {
            this._nameTxt.text = Cache.instance.petExplore.selectedConfigInfo.name;
            this._gnumTxt.text = Cache.instance.petExplore.getExploredNum().toString() + "/" + PetExploreConfig.instance.rbNum;
            this._battleListPanel.updateByPetUids(Cache.instance.petExplore.petExploreInfo.petUids);
            return;
        }

        /* internal  */onBitmapLoaderHandler(): void
        {
            this._exploreFailure.bitmapData = GlobalClass.getBitmapData(ImagesConst.ExploreFailure);
            return;
        }

        /* internal  */onReplayBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            return;
        }

        /* internal  */onBackHandler(arg1: Object /* flash.events.Event */): void
        {
            this.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetExploreBattleWindowClose));
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetExploreOpen));
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            return;
        }

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_replayBtn: GButton;

        /* internal */ /* var */_backTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_gnumTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_battleListPanel: PetExploreBattleListPanel;

        /* internal */ /* var */_exploreFailure: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_battlePetItemArray: Array<any>;
    }
